﻿using TianShu.SysParameterSetting.DAL.Abstracts.SystemParameterSetting;
using TianShu.SysParameterSetting.Service.Abstracts.SystemParameterSetting.EventDatas;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.EventBus.Distributed;

namespace TianShu.SysParameterSetting.Service.SystemParameterSetting.EventHandles
{
    /// <summary>
    /// 系统参数新增/修改事件处理
    /// </summary>
    public class SystemParameterSettingAddOrUpdateEventHandle : IDistributedEventHandler<SystemParameterSettingAddOrUpdateEventData>, ITransientDependency
    {
        public ISystemParameterSettingDal systemParameterSettingDal;
        public SystemParameterSettingAddOrUpdateEventHandle(ISystemParameterSettingDal systemParameterSettingDal)
        {
            this.systemParameterSettingDal = systemParameterSettingDal;
        }
        public async Task HandleEventAsync(SystemParameterSettingAddOrUpdateEventData eventData)
        {
            //添加或更新缓存
            await systemParameterSettingDal.AddOrUpdateSettingToCacheAsync(new DAL.Abstracts.SystemParamterSettingCacheDto
            {
                Code = eventData.Code,
                Value = eventData.Value
            });
        }
    }
}
